From b905f2f14b31bc9a060a7aea712056b73b17c036 Mon Sep 17 00:00:00 2001 From: Ian Campbell Date: Wed, 25 Jul 2012 17:39:21 +0100 Subject: [PATCH] arm: add bounds check on hypercall array Otherwise a guest can cause us to run off the end of the array. Signed-off-by: Ian Campbell Acked-by: Stefano Stabellini [ ijc -- switched to >= not > ] Committed-by: Ian Campbell --- xen/arch/arm/traps.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index f2c25b5821..d2adf4fee1 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -479,6 +479,12 @@ static void do_trap_hypercall(struct cpu_user_regs *regs, unsigned long iss) return; } + if ( regs->r12 >= ARRAY_SIZE(arm_hypercall_table) ) + { + regs->r0 = -ENOSYS; + return; + } + call = arm_hypercall_table[regs->r12].fn; if ( call == NULL ) { -- 2.30.2